package com.ctg.itrdc.sysmgr.portal.control;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.ctg.itrdc.pasp.security.dto.FuncMenuDTO;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ctg.itrdc.pasp.security.SecUser;
import com.ctg.itrdc.pasp.security.facade.IPermissionFacade;
import com.ctg.itrdc.pasp.security.utils.WebUtils;
import com.ctg.itrdc.sysmgr.portal.common.entity.CommonResult;

@Controller
@RequestMapping("/perm")
public class ExtPermissionController {
	
	@Resource
	IPermissionFacade permissionService;

	@RequestMapping("/menu_tree")
	@ResponseBody
	public CommonResult selectMenuTree() {
		SecUser ctgUser = WebUtils.getCtgUser();
		Long sysUserId = ctgUser.getSysUserId();
		Long sysPostId = ctgUser.getSysPostId();
		List<FuncMenuDTO> menuTree = permissionService.getMenuTree(sysUserId, sysPostId);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("menus", menuTree);
		map.put("user", ctgUser);
		return new CommonResult(HttpStatus.OK.toString(), "", map);
	}
}
